/**
 * @Title: AuthInterceptor
 * @Package cn.com.yiqi.wsc.portal.interceptor
 * @Description: TODO
 * Copyright: Copyright (c) 2016
 * Company: 成都壹柒互动科技有限公司
 * @author 会员系统组-胥钰淋
 * @date 2017/2/13 18:04
 * @version V1.0
 */
package cn.com.yiqi.wsc.portal.interceptor;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 *@ClassName: AuthInterceptor
 * @Description: TODO
 * @author 会员系统组-胥钰淋
 * @date 2017/2/13 18:04
 *
 */
public class AuthInterceptor implements HandlerInterceptor {

//    @Autowired
//    private ShiroBaseServiceImpl shiroBaseService;

    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        String user = (String) httpServletRequest.getSession().getAttribute("username");
        if (StringUtils.isNotEmpty(user)) {
            return true;
        }
        httpServletResponse.sendRedirect("/login/index");
        return false;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {

    }
}
